import L from 'leaflet'

// 单独引入LW
import '@/static/js/leaflet/leaflet.weather.min.js' // 全部引入
let LW = window.LW
export const getNewSpotByGrid = (map, data, legendData, options) => {
	var SpotByGrid = new LW.ContourLayer({
		method: 'idw',
		latField: 'lat',
		lonField: 'lon',
		columns: 150,
		rows: 150,
		weight: 1,
		boundMask: false,
		label: false,
		fill: true,
		fillOpacity: 0.65,
		stroke: false,
		// fillData:false,
		bounds: L.latLngBounds(L.latLng(23.173714, 115.601033), L.latLng(28.67836, 121.10568)),
		...options
	})
	const legendDataItems = legendData.items
	SpotByGrid.showContour(data, 'value', legendDataItems)
	SpotByGrid.addTo(map)
	const mask = L.geoJSON(window.boundJson).addTo(SpotByGrid)
	SpotByGrid.setMask(mask, true)
	return SpotByGrid
}
